﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>病区陪护人员当日体温</title>
    <link href="~/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/css/common.css" rel="stylesheet" type="text/css" />
    <script src="~/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="~/lib/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script src="~/Scripts/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
    <div style="height:30px;">
        <div class="sblabel">
            日期：
        </div>
        <div class="sbligerControl">
            <input type="text" id="txtDate" value="" />
        </div>
        <div class="sblabel">
            病区：
        </div>
        <div class="sbligerControl">
            <input type="text" id="txtNurseCellCode" value="" />
        </div>
        <div class="sblabel">
            开始时间：
        </div>
        <div class="sbligerControl">
            <input type="time" id="txtStime" value="09:00:00" onclick="WdatePicker({ el: this, dateFmt: 'HH:mm:ss' })" />
        </div>
        <div class="sblabel">
            结束时间：
        </div>
        <div class="sbligerControl">
            <input type="text" id="txtEtime" value="16:00:00" onclick="WdatePicker({ el: this, dateFmt: 'HH:mm:ss' })" />
        </div>
        <div class="sbligerButton">
            <input id="btnSave" type="button" value="保存" class="l-button"  />
        </div>
    </div>
    <div id="maingrid"></div>
    <script>
        // GET: /Escort/DateTempList/
        var isfristLoad = true;;
        $(function () {
            //必须页面加载后最优先绑定该事件 因为涉及到onSelected onChangeDate顺序问题
            $("#txtNurseCellCode").ligerComboBox({
                cancelable: false,
                width: 120,
                url: "/Escort/DateTempList/GetAllUnits?ram" + Math.random(),
                valueField: "DepartmentCode",
                textField: "DepartmentName",
                data: [
                      { id: "N160000", text: "N16病区" },
                      { id: "N060000", text: "N6病区" }
                ],
                valueFieldID: 'hdnNurseCellCode',
                value: "N160000",
                onSuccess: function (data) {
                    $("#txtNurseCellCode").ligerComboBox().setValue("N160000");
                },
                onSelected: function (newvalue) {
                    if (isfristLoad)
                    search(1);
                }
            });
            $("#txtDate").ligerDateEditor({
                showTime: false,
                format: "yyyy-MM-dd",
                width: 90,
                cancelable: false,
                value: CurentDate(),
                onChangeDate: function () {
                    if (isfristLoad)
                    search(1);
                }
            });
            $("#btnSave").on("click", function () {
                save();
            });
        });
        function save() {
            var datajson = grid.getData();
            datajson = (JSON.stringify(datajson));
            if (datajson == "[]") {
                $.ligerDialog.error("暂无数据可以保存");
                return;
            }
            if (IsEmpty($("#txtStime").val())) {
                $.ligerDialog.error("请输入开始时间");
                return;
            }
            if (IsEmpty($("#txtEtime").val())) {
                $.ligerDialog.error("请输入结束时间");
                return;
            }
            $.post("/Escort/DateTempList/Save", { datajson: datajson, date: $("#txtDate").val(), stime: $("#txtStime").val(), etime: $("#txtEtime").val() }, function (data, textStatus) {
                if (textStatus == "success") {
                    {
                        var r = $.parseJSON(data);
                        if (r.Result == 1) {
                            $.ligerDialog.success("保存成功")
                        }
                        else if (r.Result == 0) {
                            $.ligerDialog.error(r.Body);
                        }
                        else {
                            $.ligerDialog.error("程序错误");
                        }
                    }
                }
            })
        }
        function search(pageNumber)
        {
            isfristLoad = false;
            var queryData = {
                date: $("#txtDate").val(),
                nurseCellCode: $("#txtNurseCellCode").ligerComboBox().getValue(),
                stime: $("#txtStime").val(),
                etime: $("#txtEtime").val(),
            }
            initTable(queryData, pageNumber);
        }
        var grid;
        function initTable(queryData, pageNumber) {
            grid = $("#maingrid").ligerGrid({
                height: '100%',
                url: '/Escort/DateTempList/Search?ram=' + Math.random(),
                parms: queryData,
                page: pageNumber,
                pageSize: 1000,
                rownumbers: true,
                heightDiff: -5,
                pageSizeOptions:[1000],
                columns: [
                    { display: '床号', name: 'BED_NO', width: 80 },
                    { display: '患者姓名', name: 'PATIENT_NAME', width: 80 },
                    { display: '陪护人名称', name: 'ESCORT_NAME', width: 80 },                    
                    { display: '年龄', name: 'ESCORT_AGE', width: 80 },
                    { display: '性别', name: 'SEX_NAME', width: 80 },
                    { display: '陪护联系方式', name: 'ESCORT_PHONE', width: 100 },
                    { display: '上午体温(编辑)', name: 'MORNING_TEMP', width: 100, editor: { type: 'float' } },
                    { display: '下午体温(编辑)', name: 'AFTERNOON_TEMP', width: 100, editor: { type: 'float' } }
                ],
                enabledEdit: true,
                onSuccess: function (data, grid) { },
                onSelectRow: function (rowdata, rowindex) { }
            });
            GridNoData($("#maingrid"));
        }        
    </script>
</body>
</html>